﻿@{
    ViewBag.Title = "RVA Master Portal";
}
<!-- Document.ready -->
<script> 

    $(document).ready(function () {

        $("#tabstrip").kendoTabStrip({
            select: function (e) {
                // After FIRST click, make header smaller and fixed
                if (!$(headercontent).hasClass("shrunkenhead")) {
                    $("#headercontent").addClass("shrunkenhead");
                    $("#header").addClass("shrunkenhead");
                    $("#tabstrip").addClass("fixedhead");
                    $("#mainnav").addClass("fixedhead");
                }
                // Go back to top of this section - in case we had scrolled somewhere else.
                $('html, body').animate({
                    scrollTop: 0
                }, 500);
                
                if ($(e.item).text() == "My Schedule") {
                    viewModel.set("currentStaffID", viewModel.get("userID")); //for staff - doesn't matter to students.
                    viewModel.set("currentPersonID", viewModel.get("userID")); //for students
                    viewModel.set("laststudentdiv", e.contentElement);
                    $(e.contentElement).html(""); //this forces the tab to reload.
                }
                if ($(e.item).text() == "Search") {
                    $(e.contentElement).html(""); //this forces the tab to reload.
                }
                if (($(e.item).text() == "My Dorm")) {
                    viewModel.set("progressReportID", "DormProgressReport");
                } else {
                    viewModel.set("progressReportID", "ChildProgressReport");
                    viewModel.progressReportMasterSource.group([{ field: "StudentName" }, { field: "courseandperiod()" }]);

                }
                viewModel.set("currentStudentList", viewModel.studentTabListSource.get($(e.item).text()).get("IDList"));

                if (($(e.item).text() == "My Children") || ($(e.item).text() == "My Dorm") || ($(e.item).text() == "My Grades")) {
                    $("#"+viewModel.get("progressReportID")).html("<p>Loading Data...  Please Wait </p>");
                     viewModel.progressReportMasterSource.transport.options.read.url = crudServiceBaseUrl + "sqlsp/SP_ProgressReport_Multi_Student_Master?StudentIDList=" + viewModel.studentTabListSource.get($(e.item).text()).get("IDList");
                    viewModel.progressReportMasterSource.read();
                    $("#bystudent").kendoButton({
                        click: function (e) {
                            viewModel.progressReportMasterSource.group([{ field: "StudentName" }, { field: "courseandperiod()" }]);
                        }
                    });
                    $("#bycourse").kendoButton({
                        click: function (e) {
                            viewModel.progressReportMasterSource.group([{ field: "COURSENAME" }, { field: "StudentName" }]);
                        }
                    });
                    
                }
                if ($(e.item).text() == "GradeLookup") {
                    $("#gradesearch").kendoAutoComplete({
                        dataSource: viewModel.studentLookupSource,
                        dataTextField: "FullName",
                        filter: "contains",
                        select: function (e) {
                            viewModel.set("progressReportID", "LookupProgressReport");
                            viewModel.progressReportMasterSource.transport.options.read.url = crudServiceBaseUrl + "sqlsp/SP_ProgressReport_Multi_Student_Master?StudentIDList=" + this.dataItem(e.item.index()).SearchID;
                            viewModel.progressReportMasterSource.read();
                            
                        }
                    });
                }
            },
            dataTextField: "TabName",
            dataContentField: "Content()",
            dataContentUrlField: "ContentURL",
            dataSource: viewModel.studentTabListSource
        });


        kendo.bind($("body"), viewModel);

        viewModel.studentTabListSource.transport.options.read.url = crudServiceBaseUrl + "alltables/StudentIDsByUser(" + viewModel.get("userID") + ")";
        viewModel.studentTabListSource.read();
        viewModel.set("currentPersonID", viewModel.get("userID"));
    
    });
</script>


<div id="tabstrip">
</div>


<!-- Progress Report Template -->
<script type="text/x-kendo-tmpl" id="progress-master-template">
    <!--This is the template for the top level of the Progress Report....-->
    <li class="firstlevel">
        <span style="font-weight:bold">
            ${value}
        </span>
        <div>
            <ul class="coursepanel"  style="width:90%; margin-left:5%">
                # for (i=0; i < items.length; i++) {
                #
                <li  courseid="${items[i].items[0].COURSECODE}" studentid="${items[i].items[0].STUDENTID}">
                    <span style="font-weight:bold">${items[i].value}:</span>  &nbsp;&nbsp;&nbsp;${items[i].items[0].TERMGRADE} <span style="font-size:smaller; ">
                        ${items[i].items[0].TERMGRADEDETAIL}

                    </span>
                    <div>
                        #
                        if (items[i].items[0].TeacherName!=null) {
                        #
                        <p>
                            ${items[i].items[0].TeacherName}
                            #
                            if (items[i].items[0].TeacherEmail!=null) {
                            #
                            <a href="mailto: ${items[i].items[0].TeacherEmail}">${items[i].items[0].TeacherEmail}</a>
                            #
                            }
                            #
                        </p>
                        #
                        }
                        if (items[i].items[0].COURSEDESCRIPTION!=null) {
                        #
                        <h4>Course Comments:</h4>
                        <p>${items[i].items[0].COURSEDESCRIPTION}</p>
                        #
                        }
                        if (items[i].items[0].TERMCOMMENT!=null) {
                        #
                        <h4>Student Comments:</h4>
                        <p>${items[i].items[0].TERMCOMMENT}</p>
                        #
                        }
                        #
                        <ul id="${items[i].items[0].COURSECODE}${items[i].items[0].STUDENTID}" style="width:90%; margin-left:5%"></ul>
                        <p style="width:90%; margin-left:5%">Assignments in Pink do not have a grade yet. This could be because the assignment has not been graded or it could be that the due date is in the future or it could be that the assignment is missing.</p>
                    </div>
                </li>
                #
                }
                #
 
            </ul>
        </div>


    </li>

</script>

<script type="text/x-kendo-tmpl" id="progress-detail-template">

    <li>
        ${value}
        <div>
            <table class="progtable" style="width:90%; margin-left:5%">
                <thead>
                    <tr>
                        <th>DUE-DATE</th>
                        <th>ASSIGNMENT</th>
                        <th>POINTS</th>
                        <th>PERCENT</th>
                    </tr>
                </thead>
                <tbody>
                    # for (k=0; k < items.length; k++) {
                    currentassignment = items[k];
                    if ((currentassignment.ASSIGNMENTDESCRIPTION!=null) || (currentassignment.ASSIGNMENTCOMMENT!=null))
                    {
                    myrows=2;
                    }
                    else {
                    myrows=1;
                    }
                    #
                    <tr class="${currentassignment.GRADESTYLE}">
                        <td rowspan="${myrows}">${currentassignment.ASSIGNMENTDUEDATE}</td>
                        <td><strong>${currentassignment.ASSIGNMENTNAME}</strong></td>
                        <td>${currentassignment.ASSIGNMENTGRADE}</td>
                        <td>${currentassignment.ASSIGNMENTPERCENTLETTERGRADE}</td>
                    </tr>
                    #
                    if (myrows==2)
                    {
                    #
                    <tr class="${currentassignment.GRADESTYLE}">
                        <td colspan="3">
                            # if (currentassignment.ASSIGNMENTDESCRIPTION!=null) {
                            #
                            Description: ${currentassignment.ASSIGNMENTDESCRIPTION}<br />
                            #
                            }
                            if (currentassignment.ASSIGNMENTCOMMENT!=null) {
                            #
                            Comment: ${currentassignment.ASSIGNMENTCOMMENT}
                            #
                            }
                            #
                        </td>
                    </tr>
                    #
                    }
                    }
                    #
                </tbody>
            </table>
        </div>
    </li>
   </script>
